#include "stdafx.h"
#include "Block.h"
#include "GameConfig.h"

bool BlocksSprite::Init()
{
	if ( !m_tile[0].Create("../Media/Tile/tilenone.png") )
		return false;
	if ( !m_tile[1].Create("../Media/Tile/tile1.png") )
		return false;
	if ( !m_tile[2].Create("../Media/Tile/tile2.png") )
		return false;
	if ( !m_tile[3].Create("../Media/Tile/tile3.png") )
		return false;
	if ( !m_tile[4].Create("../Media/Tile/tile4.png") )
		return false;
	if ( !m_tile[5].Create("../Media/Tile/tile5.png") )
		return false;

	for ( int i = 0; i < 6; i++ )
		m_tile[i].SetSize(GameConfig::Get().TileSize, GameConfig::Get().TileSize);
	return true;
}

void BlocksSprite::Destroy()
{
	for ( int i = 0; i < (int)BlockType::MAXTILE; i++ )
		m_tile[i].Destroy();	
}

Sprite* BlocksSprite::GetTile(BlockType type)
{
	return &m_tile[(int)type];
}

Block::Block()
{
	Init(BlockType::NONE_TILE);
}

void Block::Init(BlockType type)
{
	m_type = type;
	m_tile = BlocksSprite::Get().GetTile(m_type);
}

bool Block::IsFree()
{
	return (m_type == BlockType::NONE_TILE);
}

void Block::Draw(float x, float y, float z)
{
	m_tile->Draw(x, y, z);
}